﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PaymentRequest.Edit.aspx.cs"
    Inherits="_PaymentRequestEdit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <!--#include virtual="include/Head.ascx"-->
    <link rel="stylesheet" type="text/css" href="assets/css/datepicker.css" />

    <script type='text/javascript' src="assets/js/jquery.ui.datepicker.js"></script>

    <link rel="stylesheet" type="text/css" href="assets/css/jquery.autocomplete.css" />
    <style type="text/css">
        .thheader{
        font-weight:bold;vertical-align:middle;text-align:center;
        font-size:11px;
        border:1px solid #ccc !important;
        line-height: 12px !important;;
        }
          table.adminlist th,    
        table.adminlist td {
        padding: 7px !important;
        }    
        .totalamount{
        font-weight:bold;
        }
        .bottom td
        {
         font-weight:bold;
         text-align:left;
        }
          input[type=text], input[type=password], textarea, select
        {
            border: none;
              line-height:22px;
            width:100% !important;;
        }
        input[type=text]:focus, input[type=password]:focus, textarea:focus, select:focus
        {
            border-color: #4488cc;
            border-style: solid;
            border-width: 1px;
            margin: 0;
            background-color: #FCFFC5 !important;
        }
    </style>

    <script type="text/javascript">
        function doDelete(strID, strName) {
            if (confirm('Bạn có thực sự muốn xóa' + strName + '?')) {
                var vnpage = getUrlVars()['page_number'];
                var strHref = "";
                if (vnpage)
                    strHref = "PaymentRequest.Edit.aspx?ID="+getUrlVars()['ID']+"&action=delete&pID=" + strID + "&page_number=" + vnpage;
                else
                    strHref = "PaymentRequest.Edit.aspx?ID="+getUrlVars()['ID']+"&action=delete&pID=" + strID;

               window.location.href = strHref;
            }
        }
        function doBack() {
          
                var vnpage = getUrlVars()['page_number'];
                var strHref = "";
                if (vnpage)
                    strHref = "PaymentRequest.aspx?page_number=" + vnpage;
                else
                    strHref =  "PaymentRequest.aspx";
                window.location.href = strHref;          
        }
        $(window).load(function() {
                 $("#ddSubjectCarr").show();
                 $("#ddSubjectCustomer").hide();
                 $("#txtPaymentSubject").hide();
        });
 
        
        jQuery("document").ready(function(){ 
           jQuery(".FileNumber_Add").hover(function () {  
                  var vurl="";
                  if($("#ddSubjectType").val()=="3" || $("#ddSubjectType").val()=="4")  
                  {
                    vurl="AjaxFile/GetAccFileNumber.ashx?subjectType=Carrier&SubjectName="+$("#ddSubjectCarr :selected").text();
                  }
                  else  if($("#ddSubjectType").val()=="5" )
                  {
                    vurl="AjaxFile/GetAccFileNumber.ashx?subjectType=Customer&SubjectName="+$("#ddSubjectCustomer :selected").text();
                  }  
                  jQuery.ajax({
                       type: "POST",
                       url: vurl,
                       success: function(msg){                                                                                             
                       var arrSource=msg.split(",");    
                       //alert("arrSource="+arrSource);                                   
                       $('.FileNumber_Add').autocomplete(arrSource);  
                       }                               
                  });                                                                    
             }); 
             jQuery(".FileNumber_Add").blur(function () {  
                  jQuery.ajax({
                       type: "POST",
                       url: "AjaxFile/GetAccFileNumber.ashx?subjectTypeValue="+$("#ddSubjectType").val()+"&FileNumber="+$(".FileNumber_Add").val(),
                         success: function(json){    
                          if(json.length>0)
                          {
                           var parsedJSON = eval('('+json+')');
                             $(".MBL_Add").get(0).value = parsedJSON.MBL;
                             $(".HBL_Add").get(0).value = parsedJSON.HBL;
                             $(".Amount_Add").get(0).value = parsedJSON.Amount;
                             $(".TotalCost_Add").get(0).value = parsedJSON.TotalCost;
                           }
                          }  
                  });                                                                    
             });  
           jQuery("#ddBankName").change(function () { 
                var sType=$("#ddSubjectType").val(); 
                if($(this).val()=="TM")
                {                    
                    if(sType=="3") //TTNCC
                    {
                         $("#txtReciprocalAccount_Debt").val("331");   
                         $("#txtReciprocalAccount_Had").val("111");   
                    }
                    else if(sType=="4" ||sType=="5") //TT COM KH, TT COM NCC
                    {
                         $("#txtReciprocalAccount_Debt").val("338");   
                         $("#txtReciprocalAccount_Had").val("111");   
                    }
                    else if(sType=="6") //TT Khac
                    {
                         $("#txtReciprocalAccount_Debt").val("");   
                         $("#txtReciprocalAccount_Had").val("111");   
                    }                    
                }
                else
                {
                    if(sType=="3") //TTNCC
                    {
                         $("#txtReciprocalAccount_Debt").val("331");   
                         $("#txtReciprocalAccount_Had").val("112");   
                    }
                    else if(sType=="6") //TT Khac
                    {
                         $("#txtReciprocalAccount_Debt").val("");   
                         $("#txtReciprocalAccount_Had").val("111");   
                    }
                }
                                                                            
             });   
             $("#ddSubjectType").change(function(){
                if ($(this).val() == "1" || $(this).val() == "5") {
                    $("#ddSubjectCarr").hide();
                    $("#ddSubjectCustomer").show();
                    $("#txtPaymentSubject").hide();                    
                }
                else if ($(this).val() == "3" || $(this).val() == "4") {
                    $("#ddSubjectCarr").show();
                    $("#ddSubjectCustomer").hide();
                    $("#txtPaymentSubject").hide();
                }
                else if ($(this).val() == "2" || $(this).val() == "6") {
                    $("#ddSubjectCarr").hide();
                    $("#ddSubjectCustomer").hide();
                    $("#txtPaymentSubject").show();
                }
                
             });
             
         });
         var arrSubjectTypeName = [
                 "THU KH","THU KHÁC","TTNCC","TTCOM NCC","TTCOM KH","TT KHÁC"
                ];
          
    </script>

</head>
<body>
    <div id="controlload">
    </div>
    <div id="body-wrapper">
        <div id="header">
            <!--#include virtual="include/top.ascx"-->
        </div>
        <div id="main-content1">
            <h2>
                ĐỀ NGHỊ THANH TOÁN: Số
                <asp:Label ID="lblPaymentNumber" runat="server"></asp:Label>
                Ngày
                <asp:Label ID="lblPaymentDate" runat="server"></asp:Label>
            </h2>
            <div class="clear">
            </div>
            <div>
                <asp:Label ID="lblError" CssClass="error" Text="" runat="server"></asp:Label></div>
            <div class="content-box">
                <form id="frmEdit" runat="server">
                    <div class="content-box-header">
                        <h3 style="cursor: s-resize;">
                            General Infomation
                            <asp:Label ID="Label1" CssClass="error" Text="" runat="server"></asp:Label>
                        </h3>
                        <div id="action_button">
                            <input id="Button1" type="button" style="float: right; margin: 9px 10px;" class="button"
                                value="&nbsp;&nbsp;Back&nbsp;&nbsp;" onclick="doBack();" />
                            <asp:Button class="button" ID="Button2" Style="float: right; margin: 9px 10px;" runat="server"
                                Text="Save" OnClick="btnSave_Click" />
                        </div>
                        <div class="clear">
                        </div>
                    </div>
                    <table cellspacing="0" cellpadding="0" width="100%" border="0" class="adminlist">
                        <tr style="background: #ECECEC;">
                            <th align="center" class="thheader" style="width: 110px;">
                                Loại đề nghị
                            </th>
                            <th align="center" class="thheader" style="width: 150px;">
                                Đối tượng TT
                            </th>
                            <th align="center" class="thheader" style="width: 70px;">
                                Hình thức TT
                            </th>
                            <th align="center" class="thheader" style="width: 40px;">
                                TK Nợ
                            </th>
                            <th align="center" class="thheader" style="width: 40px;">
                                TK Có
                            </th>
                            <th align="center" class="thheader">
                                Trạng thái
                            </th>
                            <th align="center" class="thheader">
                                Nội dung
                            </th>
                            <th align="center" class="thheader">
                                Ghi chú
                            </th>
                            <th align="center" class="thheader" style="width: 100px;">
                                Người lập
                            </th>
                            <th align="center" class="thheader" style="width: 40px;">
                                Kế toán
                            </th>
                            <th align="center" class="thheader" style="width: 40px;">
                                Người duyệt
                            </th>
                            <th align="center" class="thheader" style="width: 40px;">
                                Giám đốc
                            </th>
                        </tr>
                        <tr onmouseover="this.style.background='#dbf0c9'" onmouseout="this.style.background='#ffffff'">
                            <td>
                                <asp:DropDownList ID="ddSubjectType" runat="server" AutoPostBack="false">
                                    <asp:ListItem Text="TTNCC" Value="3"></asp:ListItem>
                                    <asp:ListItem Text="TTCOM NCC" Value="4"></asp:ListItem>
                                    <asp:ListItem Text="TTCOM KH" Value="5"></asp:ListItem>
                                    <asp:ListItem Text="TT KH&#193;C" Value="6"></asp:ListItem>
                                </asp:DropDownList>
                            </td>
                            <td>
                                <%=PaymentSubjectName %>
                                <asp:DropDownList ID="ddSubjectCarr" runat="server">
                                </asp:DropDownList>
                                <asp:DropDownList ID="ddSubjectCustomer" runat="server">
                                </asp:DropDownList>
                                <asp:TextBox class="cls" ID="txtPaymentSubject" runat="server" Width="100px" TabIndex="2"></asp:TextBox>
                            </td>
                            <td>
                                <asp:DropDownList ID="ddBankName" runat="server">
                                    <asp:ListItem Text="TM" Value="TM"></asp:ListItem>
                                    <asp:ListItem Text="VCB" Value="VCB"></asp:ListItem>
                                    <asp:ListItem Text="BIDV" Value="BIDV"></asp:ListItem>
                                    <asp:ListItem Text="TCB" Value="TCB"></asp:ListItem>
                                </asp:DropDownList>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtReciprocalAccount_Debt" runat="server" TabIndex="2"></asp:TextBox></td>
                            <td>
                                <asp:TextBox class="cls" ID="txtReciprocalAccount_Had" runat="server" TabIndex="2"></asp:TextBox></td>
                            <td>
                                <asp:TextBox class="cls" ID="txtStatus" runat="server" TabIndex="2"></asp:TextBox></td>
                            <td>
                                <asp:TextBox class="cls" ID="txtDescription" runat="server" TabIndex="2"></asp:TextBox></td>
                            <td>
                                <asp:TextBox class="cls" ID="txtNote" runat="server" TabIndex="2"></asp:TextBox></td>
                            <td>
                                <asp:TextBox class="cls" ID="txtCreateByName" runat="server" Width="100px" TabIndex="2"></asp:TextBox></td>
                            <td>
                                <asp:CheckBox class="cls" ID="cbAccountingVerify" runat="server" TabIndex="2"></asp:CheckBox>
                            </td>
                            <td>
                                <asp:CheckBox class="cls" ID="cbVerify" runat="server" TabIndex="2"></asp:CheckBox></td>
                            <td>
                                <asp:CheckBox class="cls" ID="cbDirectorVerify" runat="server" TabIndex="2"></asp:CheckBox></td>
                        </tr>
                    </table>
                    <div class="content-box-header">
                        <h3 style="cursor: s-resize;">
                            Details Infomation
                        </h3>
                    </div>
                    <div class="clear">
                    </div>
                    <fieldset>
                        <asp:Repeater ID="rptData" runat="server">
                            <ItemTemplate>
                                <tr onmouseover="this.style.background='#dbf0c9'" onmouseout="this.style.background='#ffffff'">
                                    <td>
                                        <%# DataBinder.Eval(Container.DataItem, "Index")%>
                                        <asp:HiddenField ID="ID" runat="server" Value='<%# DataBinder.Eval(Container.DataItem, "ID")%>'>
                                        </asp:HiddenField>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="FileNumber" runat="server" Width="98%" Text='<%# DataBinder.Eval(Container.DataItem, "FileNumber")%>'
                                            CssClass='<%#Eval("ID").ToString()=="-1"?"FileNumber_Add":"" %>'></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="MBL" runat="server" Width="98%" Text='<%# DataBinder.Eval(Container.DataItem, "MBL")%>'
                                            CssClass='<%#Eval("ID").ToString()=="-1"?"MBL_Add":"" %>'></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="HBL" runat="server" Width="98%" Text='<%# DataBinder.Eval(Container.DataItem, "HBL")%>'
                                            CssClass='<%#Eval("ID").ToString()=="-1"?"HBL_Add":"" %>'></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="Amount" runat="server" Width="98%" Text='<%# DataBinder.Eval(Container.DataItem, "Amount")%>'
                                            CssClass='<%#Eval("ID").ToString()=="-1"?"Amount_Add":"" %>'></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="TotalCost" runat="server" Width="98%" Text='<%# DataBinder.Eval(Container.DataItem, "TotalCost")%>'
                                            CssClass='<%#Eval("ID").ToString()=="-1"?"TotalCost_Add":"" %>'></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="TotalRequest" runat="server" Width="98%" Text='<%# DataBinder.Eval(Container.DataItem, "TotalRequest")%>'
                                            CssClass='<%#Eval("ID").ToString()=="-1"?"TotalRequest_Add":"" %>'></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="TotalDifference" runat="server" Width="98%" Text='<%# DataBinder.Eval(Container.DataItem, "TotalDifference")%>'></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="Note" runat="server" Width="98%" Text='<%# DataBinder.Eval(Container.DataItem, "Note")%>'></asp:TextBox>
                                    </td>
                                    <td>
                                        <%# DataBinder.Eval(Container.DataItem, "Action")%>
                                    </td>
                                </tr>
                            </ItemTemplate>
                            <HeaderTemplate>
                                <table cellspacing="0" cellpadding="0" width="100%" border="0" class="adminlist"
                                    editcellcontent="true">
                                    <thead>
                                        <tr>
                                            <th align="center">
                                                Index
                                            </th>
                                            <th align="center">
                                                Số file
                                            </th>
                                            <th align="center">
                                                MBL
                                            </th>
                                            <th align="center">
                                                HBL
                                            </th>
                                            <th align="center">
                                                Số lượng
                                            </th>
                                            <th align="center">
                                                Số tiền trên cost
                                            </th>
                                            <th align="center">
                                                Số tiền đề nghị
                                            </th>
                                            <th align="center">
                                                Chênh lệch
                                            </th>
                                            <th align="center">
                                                Ghi chú
                                            </th>
                                            <th align="center">
                                                Action
                                            </th>
                                        </tr>
                                    </thead>
                            </HeaderTemplate>
                            <FooterTemplate>
                                <tr class="bottom">
                                    <td colspan="4" style="text-align: right!important;">
                                        Tổng cộng
                                    </td>
                                    <td>
                                        <%=SumAmount.ToString("#,#.##")%>
                                    </td>
                                    <td>
                                        <%=SumTotal.ToString("#,#.##")%>
                                    </td>
                                    <td>
                                        <%=SumRequest.ToString("#,#.##")%>
                                    </td>
                                    <td>
                                        <%=SumDifferent.ToString("#,#.##")%>
                                    </td>
                                    <td colspan="2">
                                    </td>
                                </tr>
                                </TABLE>
                            </FooterTemplate>
                        </asp:Repeater>
                    </fieldset>
                    <div class="clear">
                    </div>
                    <div class="clear">
                    </div>
                    <div id="footer">
                        <%=strPager%>
                    </div>
                </form>
            </div>
        </div>
    </div>
</body>
</html>
